import yaml
from typing import Dict, Optional

class ModelConfig:
    def __init__(self, config_path: str = "config.yaml"):
        with open(config_path, 'r', encoding='utf-8') as f:
            self.config = yaml.safe_load(f)
    
    def get_model_config(self, model_type: str) -> Dict[str, str]:
        """
        获取指定类型模型的配置
        
        Args:
            model_type: 模型类型 ('openai' 或 'qwen')
            
        Returns:
            包含 api_key 和 base_url 的字典
        """
        if model_type not in self.config['models']:
            raise ValueError(f"Unsupported model type: {model_type}")
        
        return self.config['models'][model_type]
    
    def get_api_key(self, model_type: str) -> str:
        """获取指定类型模型的 API 密钥"""
        return self.get_model_config(model_type)['api_key']
    
    def get_base_url(self, model_type: str) -> str:
        """获取指定类型模型的基础 URL"""
        return self.get_model_config(model_type)['base_url'] 